<?PHP
  include('installer/installer.php');
  session_start();
  if($_GET['restart']){
    $_SESSION['installer'] = null;
  }
  if(!isset($_SESSION['installer'])){
    $_SESSION['installer'] = new Installer();
  }
  if($_SESSION['installer']->validateCurrentStep()){
    if($_POST['next'] or $_POST['finish']){
      $_SESSION['installer']->params[$_SESSION['installer']->step-1] = $_POST;
      $_SESSION['installer']->step++;
    }
    if($_POST['back']){
      $_SESSION['installer']->step--;
    }
  }
?>
<html>
  <head>
    <title>Installation ContentLion</title>
	<style>
	  body{
	    background-color:#000;
		color:#fff;
		font-family:Tahoma;
		padding-top:50px;
		padding-left:25px;
	  }
	  .ready{
	    color:#aaa;
	  }
	  .current{
	    font-style:italic;
	  }
	  #logo{
	    float:right;
		margin:50px;
	  }
	  #navigation{
	    margin-top:20px;
	  }
	  #btnBack{
	    float:left;
		margin-right:200px;
	  }
	  a{
	    color:#fff;
	  }
	  a:visited{
	    color:#fff;
	  }
	  #content{
	    width:400px;
	  }
	  .right{
	    color:#0f0;
	  }
	  .wrong{
	    color:#f00;
	  }
	</style>
  </head>
  <body>
    <img id="logo" src="/installer/logo.jpg" />
    <ol>
      <?PHP
        $i = 1;
        foreach($_SESSION['installer']->steps as $step){
          echo "<li ";
          if($i < $_SESSION['installer']->step){
            echo "class='ready'>";
          }
          elseif($i == $_SESSION['installer']->step){
            echo "class='current'>";
          }
          else{
            echo "class='wait'>";
          }
          echo $step['headline']."</li>";
          $i++;
        }
      ?>
    </ol>
    <h1><?PHP echo $_SESSION['installer']->getHeadline(); ?></h1>
    <form action="/install.php" method="POST">
      <?PHP
        echo $_SESSION['installer']->getContent();
		if(!$_SESSION['installer']->isInstalled){
      ?>
        <div id="navigation">
          <?PHP
            if($_SESSION['installer']->showBackButton()){
          ?>
          <input id="btnBack" type="submit" name="back" value="Zur&uuml;ck" />
          <?PHP
            }
            if($_SESSION['installer']->showNextButton()){
          ?>
          <input id="btnNext" type="submit" name="next" value="Weiter" />
          <?PHP
            }
            if($_SESSION['installer']->showFinishButton()){
          ?>
          <input id="btnFinish" type="submit" name="finish" value="Abschlie&szlig;en" />
          <?PHP
            }
          }
		  else{
		    $_SESSION['installer']->destroy();
			?>
			<script language="JavaScript"><!--
var zeit=(new Date()).getTime(); 
var stoppZeit=zeit+3000; 
while((new Date()).getTime()<stoppZeit){}; 
window.location.href="http://<?PHP echo $_SERVER['HTTP_HOST']; ?>/admin/";
// --></script> 
			<?PHP
		  }
		?>
      </div>
    </form>
  </body>
</html>